<script setup>
import { watch, withDefaults } from "vue";
import { useImageVerify } from "./hook";

defineOptions({
  name: "ReImageVerify"
});

const props = withDefaults(defineProps(), {
  code: ""
});

const emit = defineEmits();

const { domRef, imgCode, setImgCode, getImgCode } = useImageVerify();

watch(
  () => props.code,
  newValue => {
    setImgCode(newValue);
  }
);
watch(imgCode, newValue => {
  // emit("update:code", newValue);
});

defineExpose({ getImgCode });
</script>

<template>
  <canvas
    ref="domRef"
    width="120"
    height="40"
    @click="getImgCode"
  />
</template>
